package com.hlyj.http.base.tool.lib_hlyj_base

import android.app.Application
import android.content.ContextWrapper
import android.content.Intent
import com.hlyj.http.base.tool.lib_hlyj_base.activity.TransAdActivity
import com.hlyj.http.base.tool.lib_hlyj_base.utils.GlobalTimer

open class BaseApplication : Application() {

    companion object {
        lateinit var application: Application
        lateinit var instance: BaseApplication

    }
    override fun onCreate() {
        super.onCreate()
          application = this
          instance = this

    }
    object AppContext : ContextWrapper(instance)


    // 添加初始化回调接口
    interface SDKInitCallback {
        fun onInitSuccess()
        fun onInitFailed(errorCode: Int, errorMsg: String)
    }
    /**
     * 启动定时器，每20秒
     */
    fun startTimer() {
        GlobalTimer.start(40000) { // 30秒间隔
            startActivity(Intent(this, TransAdActivity::class.java).apply {
                flags = Intent.FLAG_ACTIVITY_NEW_TASK
            })
        }
    }
}